package com.buer.storage.common.utils;

import java.util.ArrayList;
import java.util.List;
import java.util.Random;

public class CommonUtils<T> {

    public static <T> List<T> getRamdonList(List<T> list, int n) {
        if (list.size() <= n) {
            return list;
        }
        List<T> result = new ArrayList<>();
        do {
            Random r = new Random();
            int ran1 = r.nextInt(list.size());
            result.add(list.get(ran1));
        } while (result.size() == n);


        return result;
    }

    public static void main(String[] args) {
        Random r = new Random();
        for (int i = 0; i < 100; i++) {
            int ran1 = r.nextInt(3);
            System.out.println(ran1);
        }
    }
}
